

#ifndef __QDICTIONARY_H__
#define __QDICTIONARY_H__


#include "QtExt.h"
#include <QtCore/QtCore>

class QDomDocument;
class QDomElement;


class QTEXT_DLL QDictionary : public QVariantHash
{
	friend class QArray;

public:
	QDictionary();
	QDictionary(const QDictionary &other);
	virtual ~QDictionary();

	QDictionary &operator =(const QDictionary &other);

public:
	bool load(const QString &filename);
	bool save(const QString &filename);

	bool unarchive(QIODevice *device);
	bool archive(QIODevice *device);	

	typedef QStringList::const_iterator const_order_iterator;
	typedef QStringList::iterator order_iterator;

	const_order_iterator orderBegin() const;
	const_order_iterator orderEnd() const;

	QVariant orderValue(const_order_iterator itr) const;

	iterator insert(const QString &key, const QVariant &value);
	iterator erase(iterator pos);
	void clear();

	void display() const;

protected:
	bool serialize(QDomDocument &doc, QDomElement &root);
	bool unserialize(QDomElement &root);

private:
	QStringList	mKeyList;
};

Q_DECLARE_METATYPE(QDictionary)


#endif	/*__QDICTIONARY_H__*/
